package xdu.lz.stage2_design_pattern.chapter5_reader_writer_pattern;

public class ReaderWorker extends Thread {
    private final ShareData shareData;

    public ReaderWorker(ShareData shareData) {
        this.shareData = shareData;
    }

    @Override
    public void run() {
        try {
            while (true){
                char[] chars = shareData.read();
                System.out.println(
                        Thread.currentThread().getName() + " read " + new String(chars));
            }
        } catch (InterruptedException e) {
            System.out.println(Thread.currentThread()+getName()+"读操作被中断，结束了任务");
        }
    }
}
